target("config-env")
    set_default(false)
    set_kind("phony")
    add_deps("toolchain-env")
    on_build(function (target) 
        import("core.project.project")
        local toolchain_env = project.target("toolchain-env")
        local package_env = project.target("toolchain-package-env")
        local package_info = package_env:get("toolchain.source.config")
        target:set("toolchain.config.source_dir", path.join(toolchain_env:get("toolchain.source_dir"), package_info.dirname))
        target:set("toolchain.config.sub", path.join(target:get("toolchain.config.source_dir"), "config.sub"))
        target:set("toolchain.config.guess", path.join(target:get("toolchain.config.source_dir"), "config.guess"))

        import("core.base.option")
        if option.get("verbose") then
            print("toolchain.source.config: ", package_info)
            print("toolchain.config.source_dir: ", target:get("toolchain.config.source_dir"))
            print("toolchain.config.sub: ", target:get("toolchain.config.sub"))
            print("toolchain.config.guess: ", target:get("toolchain.config.guess"))
        end
    end)

target("config-download")
    set_default(false)
    set_kind("phony")
    add_deps("config-env")
    on_build(function (target)
        import("core.project.project")
        import("package")
        local toolchain_env = project.target("toolchain-env")
        local package_env = project.target("toolchain-package-env")
        package.download(package_env:get("toolchain.source.config"), toolchain_env:get("toolchain.source_dir"))
        package.patch(package_env:get("toolchain.source.config"), toolchain_env:get("toolchain.source_dir"))
    end)
